<!--
  ~ Licensed to the Apache Software Foundation (ASF) under one or more
  ~ contributor license agreements.  See the NOTICE file distributed with
  ~ this work for additional information regarding copyright ownership.
  ~ The ASF licenses this file to You under the Apache License, Version 2.0
  ~ (the "License"); you may not use this file except in compliance with
  ~ the License.  You may obtain a copy of the License at
  ~
  ~     http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License.
  -->

<h2 mat-dialog-title>Create Process Group</h2>
<form class="create-process-group-form" [formGroup]="createProcessGroupForm">
    <mat-dialog-content>
        <mat-form-field>
            <mat-label>Name</mat-label>
            <input matInput formControlName="newProcessGroupName" type="text" />
        </mat-form-field>
        <mat-form-field>
            <mat-label>Parameter Context</mat-label>
            <mat-select formControlName="newProcessGroupParameterContext">
                @for (option of parameterContextsOptions; track option) {
                    @if (option.description) {
                        <mat-option
                            [value]="option.value"
                            nifiTooltip
                            [tooltipComponentType]="TextTip"
                            [tooltipInputData]="option.description"
                            [delayClose]="false"
                            >{{ option.text }}</mat-option
                        >
                    } @else {
                        <mat-option [value]="option.value">{{ option.text }}</mat-option>
                    }
                }
            </mat-select>
        </mat-form-field>
    </mat-dialog-content>
    @if ({ value: (saving$ | async)! }; as saving) {
        <mat-dialog-actions align="end">
            <button mat-button mat-dialog-close>Cancel</button>
            <button
                [disabled]="
                    !createProcessGroupForm.dirty ||
                    createProcessGroupForm.invalid ||
                    saving.value ||
                    createProcessGroupForm.pending
                "
                type="button"
                (click)="createProcessGroup()"
                mat-flat-button>
                <span *nifiSpinner="saving.value">Add</span>
            </button>
        </mat-dialog-actions>
    }
</form>
